package za.co.smartmi.model;

import java.io.Serializable;
import java.util.Date;

public class SystemUser implements Serializable
{
	/** 
	 * This attribute maps to the column username in the system_user table.
	 */
	protected String username;

	/** 
	 * This attribute maps to the column password in the system_user table.
	 */
	protected String password;

	/** 
	 * This attribute maps to the column status in the system_user table.
	 */
	protected String status;

        protected boolean isEnabled;
	/** 
	 * This attribute maps to the column startdate in the system_user table.
	 */
	protected Date startdate;

	/** 
	 * This attribute maps to the column lastlogindate in the system_user table.
	 */
	protected Date lastlogindate;

	/**
	 * Method 'SystemUser'
	 * 
	 */
	public SystemUser()
	{
	}

	/**
	 * Method 'getUsername'
	 * 
	 * @return String
	 */
	public String getUsername()
	{
		return username;
	}

	/**
	 * Method 'setUsername'
	 * 
	 * @param username
	 */
	public void setUsername(String username)
	{
		this.username = username;
	}

	/**
	 * Method 'getPassword'
	 * 
	 * @return String
	 */
	public String getPassword()
	{
		return password;
	}

	/**
	 * Method 'setPassword'
	 * 
	 * @param password
	 */
	public void setPassword(String password)
	{
		this.password = password;
	}

	/**
	 * Method 'getStatus'
	 * 
	 * @return String
	 */
	public String getStatus()
	{
		return status;
	}

        public boolean isEnabled() {
            if (status.equals("A")) {
                isEnabled = true;
            } else {
                isEnabled = false;
            }            
            return isEnabled;
        }
        
	/**
	 * Method 'setStatus'
	 * 
	 * @param status
	 */
	public void setStatus(String status)
	{
		this.status = status;
	}

	/**
	 * Method 'getStartdate'
	 * 
	 * @return Date
	 */
	public Date getStartdate()
	{
		return startdate;
	}

	/**
	 * Method 'setStartdate'
	 * 
	 * @param startdate
	 */
	public void setStartdate(Date startdate)
	{
		this.startdate = startdate;
	}

	/**
	 * Method 'getLastlogindate'
	 * 
	 * @return Date
	 */
	public Date getLastlogindate()
	{
		return lastlogindate;
	}

	/**
	 * Method 'setLastlogindate'
	 * 
	 * @param lastlogindate
	 */
	public void setLastlogindate(Date lastlogindate)
	{
		this.lastlogindate = lastlogindate;
	}

	/**
	 * Method 'equals'
	 * 
	 * @param _other
	 * @return boolean
	 */
	public boolean equals(Object _other)
	{
		if (_other == null) {
			return false;
		}
		
		if (_other == this) {
			return true;
		}
		
		if (!(_other instanceof SystemUser)) {
			return false;
		}
		
		final SystemUser _cast = (SystemUser) _other;
		if (username == null ? _cast.username != username : !username.equals( _cast.username )) {
			return false;
		}
		
		if (password == null ? _cast.password != password : !password.equals( _cast.password )) {
			return false;
		}
		
		if (status == null ? _cast.status != status : !status.equals( _cast.status )) {
			return false;
		}
		
		if (startdate == null ? _cast.startdate != startdate : !startdate.equals( _cast.startdate )) {
			return false;
		}
		
		if (lastlogindate == null ? _cast.lastlogindate != lastlogindate : !lastlogindate.equals( _cast.lastlogindate )) {
			return false;
		}
		
		return true;
	}

	/**
	 * Method 'hashCode'
	 * 
	 * @return int
	 */
	public int hashCode()
	{
		int _hashCode = 0;
		if (username != null) {
			_hashCode = 29 * _hashCode + username.hashCode();
		}
		
		if (password != null) {
			_hashCode = 29 * _hashCode + password.hashCode();
		}
		
		if (status != null) {
			_hashCode = 29 * _hashCode + status.hashCode();
		}
		
		if (startdate != null) {
			_hashCode = 29 * _hashCode + startdate.hashCode();
		}
		
		if (lastlogindate != null) {
			_hashCode = 29 * _hashCode + lastlogindate.hashCode();
		}
		
		return _hashCode;
	}

	/**
	 * Method 'createPk'
	 * 
	 * @return SystemUserPk
	 */
	public SystemUserPk createPk()
	{
		return new SystemUserPk(username);
	}

	/**
	 * Method 'toString'
	 * 
	 * @return String
	 */
	public String toString()
	{
		StringBuffer ret = new StringBuffer();
		ret.append( "za.co.smartmi.dto.SystemUser: " );
		ret.append( "username=" + username );
		ret.append( ", password=" + password );
		ret.append( ", status=" + status );
		ret.append( ", startdate=" + startdate );
		ret.append( ", lastlogindate=" + lastlogindate );
		return ret.toString();
	}

}
